
import request from '@/utils/request'
import Config from '@/config';

export function getChatData(action,data) {
  return request({
    c:action,
    data:data,
    error:'errorToast'
  });  
}

export function getGridField(controller,data) {
  return request({
    c:controller + '/getGridField',
    data:data,
    error:'errorToast'
  });  
  
}
export function getList(url,data) {
  return request({
    c:url,
    data:data
  });  
  
}
export function getPage(url,data) {
  return request({
    c:url,
    data:data,
    reject:true
  });  
  
}
export function submitData(action,data) {
  return request({
    c:action,
    data:data,
    loading:'正在提交',
    error:'errorToast'
  });  
}
export function addData(url,data) {
  return request({
    c:url,
    data:data,
    loading:'正在提交',
    error:'errorToast'
  });  
}
export function editData(url,data) {
  return request({
    c:url,
    data:data,
    loading:'正在提交',
    error:'errorToast'
  });  
}
export function getEdit(url,params = {}) {
  return request({
    c:url,
    method:params.method,
    data:params.data ? params.data : {},
    loading:'正在读取',
    error:'errorToast'
  });  
}
export function delData(url,params = {}) {
  return request({
    c:url,
    method:params.method,
    data:params.data ? params.data : {},
    loading:'正在删除',
    error:'errorToast'
  });  
}
export function delDataMulti(url,params = {}) {
  return request({
    c:url,
    method:params.method,
    data:params.data ? params.data : {},
    loading:'正在删除',
    error:'errorToast'
  });  
}
export function delSure(url,id) {
  return request({
    c:url,
    data:{id:id},
    loading:'正在查询关联',
    error:'errorToast'
  });  
}
export function getSelectData(dataUrl) {
  return request({
    c:dataUrl,
    data:{},
    error:'errorToast'
  });  
}
export function getComboboxData(dataUrl,data) {
  return request({
    c:dataUrl,
    data:data,
    reject:true,
    error:'errorToast'
  });  
}
export function getTreeData(dataUrl,isRoot = 0){
  return request({
    c:dataUrl,
    data:{isRoot:isRoot},
    error:'errorToast'
  }); 
}
export function getInfo(data) {
  return request({
      c:'User/getLoginInfo',
      data: data,
      method: 'POST'
  });
  return;
  return request({
    url: 'http://62.234.60.213/tp6/public/admin/v1/User/accountLogin',
    method: 'post',
    params: {
      account:'15266666666',
      password:'111111'
    }
  })

}
export function getRouters(){
  return request({
    c:'User/getRouters',
    error:'toast',
  })
}
export function platformAppLogin(){
  return request({
    c: 'PlatformApp/platformAppLogin',
    data: {
      appid:Config.appid,
      secret:Config.secret
    },
    error:'toast',
    method: 'POST'
  });
}
export function logout() {
  return request({
    c: 'User/logout',
    data: {},
    error:'toast',
    method: 'POST'
  });
  return
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}
